/*
 *
 *  * | Licensed 未经许可不能去掉「OPENIITA」相关版权
 *  * +----------------------------------------------------------------------
 *  * | Author: xw2sy@163.com
 *  * +----------------------------------------------------------------------
 *
 *  Copyright [2024] [OPENIITA]
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 * /
 */

package cc.iotkit.manager.service.impl;

import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging;
import cc.iotkit.common.satoken.utils.LoginHelper;
import cc.iotkit.common.utils.MapstructUtils;
import cc.iotkit.data.manager.IBizWorkorderMaintenance;
import cc.iotkit.manager.dto.bo.biz.BizWorkorderMaintenanceBo;
import cc.iotkit.manager.dto.vo.biz.BizWorkorderMaintenanceVo;
import cc.iotkit.manager.service.IBizWorkorderMaintenanceService;
import cc.iotkit.model.biz.BizWorkorderMaintenance;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collection;
import java.util.List;

/**
 * 租户Service业务层处理
 *
 * @author Michelle.Chung
 */
@RequiredArgsConstructor
@Service
public class BizWorkorderMaintenanceServiceImpl implements IBizWorkorderMaintenanceService {

    private final IBizWorkorderMaintenance sysBizWorkorderMaintenanceData;

    public BizWorkorderMaintenanceVo queryByPid(Long id) {
        return MapstructUtils.convert(sysBizWorkorderMaintenanceData.findByPid(id),BizWorkorderMaintenanceVo.class);
    }

    public BizWorkorderMaintenanceVo queryById(Long id) {
        return MapstructUtils.convert(sysBizWorkorderMaintenanceData.findById(id),BizWorkorderMaintenanceVo.class);
    }

    /**
     * 新增保存角色信息
     *
     * @param data 角色信息
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean save(BizWorkorderMaintenanceBo data) {

        sysBizWorkorderMaintenanceData.save(data.to(BizWorkorderMaintenance.class));
        return true;
    }

    public void deleteByPid(Collection<Long> pid){
            sysBizWorkorderMaintenanceData.deleteByPid(pid);
    }

    @Override
    public boolean deleteById(Long id) {
        sysBizWorkorderMaintenanceData.deleteById(id);
        return true;
    }

    @Transactional
    public boolean deleteByIds(Collection<Long> ids) {
        sysBizWorkorderMaintenanceData.deleteByIds(ids);
        return true;
    }



    @Override
    public Paging<BizWorkorderMaintenanceVo> queryPageList(PageRequest<BizWorkorderMaintenanceBo> request) {
        Paging<BizWorkorderMaintenance> pages=sysBizWorkorderMaintenanceData.findAllByConditions(request.to(BizWorkorderMaintenance.class));
        return pages.to(BizWorkorderMaintenanceVo.class);
    }

    @Override
    public List<BizWorkorderMaintenanceVo> queryList(BizWorkorderMaintenanceBo bo) {
        List<BizWorkorderMaintenance> list=sysBizWorkorderMaintenanceData.findAllByCondition(bo.to(BizWorkorderMaintenance.class));
        return MapstructUtils.copyListToList(list,BizWorkorderMaintenanceVo.class);
    }



}
